import request from '@/common/request';

// 账号登录
export const accountLogin = (data) =>
	request({
		url: '/user/api/user/accountLogin',
		method: 'POST',
		data,
		custom: {
			showSuccess: true,
			loadingMsg: '登录中',
		},
	});

// 车辆管理
export const stat = (params) =>
	request({
		url: '/staff/stat',
		method: 'get',
		params,
		custom: {
			showSuccess: false,
		},
	});
// 车辆查询
export const carSearch = (params) =>
	request({
		url: '/staff/carSearch',
		method: 'get',
		params,
		custom: {
			showSuccess: false,
			showLoading: true,
			showError: true,
		},
	});
// 确认缴费
export const confirmPay = (bookId) =>
	request({
		url: `/staff/confirmPay/${bookId}`,
		method: 'put',
		custom: {
			showSuccess: true,
			showLoading: true,
			showError: true,
		},
	});
// 车位查询
export const spaceSearch = (params) =>
	request({
		url: `/staff/spaceSearch`,
		method: 'get',
		params,
		custom: {
			showSuccess: true,
			showLoading: true,
			showError: true,
		},
	});
//取分区列表
export const zoneList = (params = {}) =>
	request({
		url: `/staff/zoneList`,
		method: 'get',
		params,
		custom: {
			showSuccess: false,
			showLoading: false,
			showError: true,
		},
	});
// 	查询空闲车位
export const zoneSpace = (params = {}) =>
	request({
		url: `/staff/zoneSpace`,
		method: 'get',
		params,
		custom: {
			showSuccess: false,
			showLoading: true,
			showError: true,
		},
	});
// 预约查询
export const searchBooking = (params) =>
	request({
		url: '/staff/searchBooking',
		method: 'get',
		params,
		custom: {
			showSuccess: false,
			showLoading: true,
			showError: true,
		},
	});
// 安检登记准备
export const prepare = (params) =>
	request({
		url: '/staff/prepare',
		method: 'get',
		params,
		custom: {
			showSuccess: false,
			showLoading: true,
			showError: true,
		},
	});
// 安检登记车牌查询
export const prepareSearchCarPlateNo = (params) =>
	request({
		url: '/staff/prepareSearchCarPlateNo',
		method: 'get',
		params,
		custom: {
			showSuccess: false,
			showLoading: true,
			showError: true,
		},
	});
//保存安检登记
export const carRegister = (data) =>
	request({
		url: '/staff/carRegister',
		method: 'POST',
		data,
	});
//巡检上报准备
export const prepareDailySafeCheck = (safeId) =>
	request({
		url: `/staff/prepareDailySafeCheck/${safeId}`,
		method: 'get',
		custom: {
			showSuccess: false,
			showLoading: true,
			showError: true,
		},
	});
//巡检上报
export const safecheck = (data) =>
	request({
		url: `/staff/safecheck/${data.safeId}`,
		method: 'post',
		data,
		custom: {
			showSuccess: true,
			showLoading: true,
			showError: true,
		},
	});
// 异常上报准备
export const prepareBookException = (params = {}) =>
	request({
		url: '/staff/prepareBookException',
		method: 'get',
		params,
		custom: {
			showSuccess: false,
			showLoading: true,
			showError: true,
		},
	});
// 图片上传
export const upload = (filePath) =>
	request({
		url: '/staff/upload',
		method: 'UPLOAD',
		filePath,
		name: 'file',
		custom: {
			showSuccess: false,
			showLoading: true,
			showError: true,
		},
	})
// 异常上报
export const bookexception = (data = {}) =>
	request({
		url: '/staff/bookexception',
		method: 'post',
		data,
		custom: {
			showSuccess: true,
			showLoading: true,
			showError: true,
		},
	});
// 隐患上报准备
export const prepareHiddenDanger = (params = {}) =>
	request({
		url: '/staff/prepareHiddenDanger',
		method: 'get',
		params,
		custom: {
			showSuccess: false,
			showLoading: true,
			showError: true,
		},
	});
// 隐患上报
export const hiddendanger = (data = {}) =>
	request({
		url: '/staff/hiddendanger',
		method: 'post',
		data,
		custom: {
			showSuccess: true,
			showLoading: true,
			showError: true,
		},
	});
// 异常记录
export const exceptionRecord = (params = {}) =>
	request({
		url: '/staff/exception/list',
		method: 'get',
		params,
		custom: {
			showSuccess: false,
			showLoading: true,
			showError: true,
		},
	});
// 巡检记录
export const safecheckRecord = (params = {}) =>
	request({
		url: '/staff/safecheck/list',
		method: 'get',
		params,
		custom: {
			showSuccess: false,
			showLoading: true,
			showError: true,
		},
	});
// 个人资料
export const profile = () =>
	request({
		url: '/staff/me',
		method: 'GET',
		custom: {
			showLoading: false,
			auth: true,
		},
	})

// 消息列表
export const message = (params = {}) => 
	request({
		url: '/staff/message',
		method: 'GET',
		params,
		custom: {
			showLoading: false,
			auth: true,
		},
	})
	// 消息设置已读
export const messageRead = (messageId) =>
	request({
		url: `/staff/message/read/${messageId}`,
		method: 'POST',
		header: {
			'Content-Type':'application/x-www-form-urlencoded'
		},
		custom: {
			showLoading: false,
			showError:false,
			auth: true,
		},
	})
// 统一认证Code登录
export const login = (data) =>
	request({
		url: '/staff/oauth/login',
		method: 'POST',
		header: {
			'Content-Type':'application/x-www-form-urlencoded'
		},
		data,
	});
	
// 账号登出
export const logout = (data) =>
	request({
		url: '/user/api/user/logout',
		method: 'POST',
		data,
	});